home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Chunky / ChunkySingle.s < prev    next >
Encoding:
Text File  |  1997-07-08  |  4.2 KB  |  183 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Chunky Pixel List
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;This demo is like the other pixel list demos but uses a CHUNKY8 screen type.
  7. ;Then screen size has been kept very small as the C2P routine is too slow,
  8. ;but this will be improved in the next version.  The good thing is that
  9. ;because the routine is transparent, using a graphics card would mean that
  10. ;this demo would run at the maximum possible speed (ie the chunky screen
  11. ;would be displayable, so no c2p would be needed).
  12. ;
  13. ;Press LMB to exit.
  14.  
  15.     INCDIR    "INCLUDES:"
  16.     INCLUDE    "games/games_lib.i"
  17.     INCLUDE    "games/games.i"
  18.  
  19.     SECTION    "DrawPixel",CODE
  20.  
  21. ;===========================================================================;
  22. ;                             INITIALISE DEMO
  23. ;===========================================================================;
  24.  
  25.     STARTGMS
  26.  
  27. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  28.     move.l    GMSBase(pc),a6
  29.     CALL    AllocBlitter
  30.     tst.l    d0
  31.     bne.s    .Error_Blitter
  32.  
  33.     lea    ScreenTags(pc),a0
  34.     CALL    ShowScreen
  35.     tst.l    d0
  36.     beq.s    .Error_Screen
  37.  
  38.     CALL    InitJoyPorts
  39.  
  40.     bsr.s    Main
  41.  
  42. .ReturnToDOS
  43.     move.l    GMSBase(pc),a6
  44.     move.l    Screen(pc),a0
  45.     CALL    DeleteScreen
  46. .Error_Screen
  47.     CALL    FreeBlitter
  48. .Error_Blitter
  49.     MOVEM.L    (SP)+,A0-A6/D1-D7
  50.     moveq    #ERR_OK,d0
  51.     rts
  52.  
  53. ;===========================================================================;
  54. ;                                MAIN LOOP
  55. ;===========================================================================;
  56.  
  57. Main:
  58. .loop    move.l    Screen(pc),a1
  59.     move.l    GS_Bitmap(a1),a0
  60.     move.l    GS_MemPtr1(a1),BMP_Data(a0)
  61.     CALL    ClearBitmap
  62.  
  63.     lea    MList(pc),a2    ;a2 = Pointer to pixel list.
  64.     move.l    a2,a3    ;Drop the pixels here.
  65.     moveq    #31-1,d7
  66. .drop    addq.w    #1,2(a3)    ;a3 = YCoord+1
  67.     subq.l    #1,4(a3)    ;a3 = (Colour)-1
  68.     bge.s    .colok
  69.     clr.l    4(a3)
  70. .colok    addq.w    #8,a3
  71.     dbra    d7,.drop
  72.  
  73.     lea    MouseX(pc),a5
  74.     moveq    #JPORT1,d0
  75.     moveq    #JT_ZBXY,d1
  76.     CALL    ReadJoyPort
  77.     btst    #MB_LMB,d0
  78.     bne.s    .done
  79.     move.w    d0,d1
  80.     ext.w    d1    ;d1 = Extend the Y byte.
  81.     add.w    d1,2(a5)    ;d1 = (MouseY)+ChangeY
  82.     asr.w    #8,d0    ;d0 = Extend the X byte.
  83.  
  84.     add.w    (a5),d0
  85.     move.l    Screen(pc),a0
  86. .ChkRX    cmp.w    GS_ScrWidth(a0),d0
  87.     blt.s    .ChkLX
  88.     move.w    GS_ScrWidth(a0),(a5)
  89.     bra.s    .Calculate
  90.  
  91. .ChkLX    tst.w    d0
  92.     bgt.s    .okX
  93.     clr.w    (a5)
  94.     bra.s    .Calculate
  95. .okX    move.w    d0,(a5)
  96.  
  97. .Calculate
  98.     move.l    (a5),-(sp)
  99.     moveq    #2,d1
  100.     CALL    FastRandom
  101.     subq.w    #1,d0
  102.     add.w    d0,(a5)
  103.  
  104.     moveq    #2,d1
  105.     CALL    FastRandom
  106.     subq.w    #1,d0
  107.     add.w    d0,2(a5)
  108.  
  109.     move.l    a2,a3
  110.     moveq    #31-1,d7
  111. .tloop    move.l    8(a3),(a3)
  112.     move.l    12(a3),4(a3)
  113.     addq.w    #8,a3
  114.     dbra    d7,.tloop
  115.  
  116.     move.l    Screen(pc),a0
  117.     move.l    GS_Bitmap(a0),a0
  118.     lea    PixelList(pc),a1    ;a1 = Pixel list.
  119.     CALL    DrawPixelList    ;>> = Draw pixels with clipping.
  120.     move.l    (sp)+,(a5)
  121.  
  122.     CALL    WaitVBL
  123.     bra    .loop
  124. .done    rts
  125.  
  126. ;===========================================================================;
  127. ;                                  DATA
  128. ;===========================================================================;
  129.  
  130. ScreenTags:
  131.     dc.l    TAGS_GAMESCREEN
  132. Screen:    dc.l    0
  133.     dc.l    GSA_ScrWidth,256
  134.     dc.l    GSA_ScrHeight,128
  135.     dc.l    GSA_Palette,.palette
  136.     dc.l    GSA_AmtColours,32
  137.     dc.l    GSA_ScrType,CHUNKY8
  138.     dc.l    GSA_Attrib,CENTRE
  139.     dc.l    TAGEND
  140.  
  141. .palette
  142.     dc.l $000000,$101010,$171717,$202020,$272727,$303030,$373737,$404040
  143.     dc.l $474747,$505050,$575757,$606060,$676767,$707070,$777777,$808080
  144.     dc.l $878787,$909090,$979797,$a0a0a0,$a7a7a7,$b0b0b0,$b7b7b7,$c0c0c0
  145.     dc.l $c7c7c7,$d0d0d0,$d7d7d7,$e0e0e0,$e0e0e0,$f0f0f0,$f7f7f7,$ffffff
  146.  
  147. PixelList:
  148.     dc.w    32,PXL_SIZEOF    ;Amount of entries, EntrySize.
  149.     dc.l    MList    ;Pointer to pixel list array.
  150. MList    PIXEL    16,12,00    ;First pixel to draw (at back)
  151.     PIXEL    16,12,00    ;X/Y/Colour
  152.     PIXEL    16,12,00    ;..
  153.     PIXEL    16,12,00    ;..
  154.     PIXEL    16,12,00    ;..
  155.     PIXEL    16,12,00    ;..
  156.     PIXEL    16,12,00    ;..
  157.     PIXEL    16,12,00    ;..
  158.     PIXEL    16,12,00    ;..
  159.     PIXEL    16,12,00    ;..
  160.     PIXEL    16,12,00    ;..
  161.     PIXEL    16,12,00    ;..
  162.     PIXEL    16,12,00    ;..
  163.     PIXEL    16,12,00    ;..
  164.     PIXEL    16,12,00    ;..
  165.     PIXEL    16,12,00    ;..
  166.     PIXEL    16,12,00    ;..
  167.     PIXEL    16,12,00    ;..
  168.     PIXEL    16,12,00    ;..
  169.     PIXEL    16,12,00    ;..
  170.     PIXEL    16,12,00    ;..
  171.     PIXEL    16,12,00    ;..
  172.     PIXEL    16,12,00    ;..
  173.     PIXEL    16,12,00    ;..
  174.     PIXEL    16,12,00    ;..
  175.     PIXEL    16,12,00    ;..
  176.     PIXEL    16,12,00    ;..
  177.     PIXEL    16,12,00    ;..
  178.     PIXEL    16,12,00    ;..
  179.     PIXEL    16,12,00    ;..
  180.     PIXEL    16,12,00    ;..
  181. MouseX    PIXEL    16,12,31    ;Last pixel to draw (in front)
  182.  
  183.